package com.leetcode.greedy;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author Dennis Li
 * @date 2020/7/21 23:06
 */
public class FindMinArrowShots_452 {

    public int findMinArrowShots(int[][] points) {
        if (points.length == 0) return 0;
        Arrays.sort(points, Comparator.comparingInt(o -> o[1]));
        int res = 1;
        int end = points[0][1];
        for (int i = 1; i < points.length; i++) {
            if (points[i][0] > end) {
                end = points[i][1];
                res++;
            }
        }
        return res;
    }

}
